Skip to content

Do not enforce 0-99 priority rule on system events#94

Merged
pavelsavara merged 1 commit into
robo-code:mainfrom
pavelsavara:fix/system-event-priority-noise
Jun 22, 2026
Merged

Do not enforce 0-99 priority rule on system events#94
pavelsavara merged 1 commit into
robo-code:mainfrom
pavelsavara:fix/system-event-priority-noise

Conversation

@pavelsavara

@pavelsavara pavelsavara commented Jun 21, 2026

Copy link
Copy Markdown
Member

Problem

System events (WinEvent, BattleEndedEvent, SkippedTurnEvent, RoundEndedEvent, DeathEvent) have a fixed priority of 100, which is outside the 0-99 range allowed for robot-defined events. When the engine (or tooling that reconstructs events) stamps such an event with its per-class default priority, Event.setPriorityHidden() clamped it to 99 and printed misleading noise to the robot console:

SYSTEM: Priority for robocode.WinEvent will be 99

Fix

  • Event.setPriorityHidden() now returns early for critical (system) events, leaving their priority untouched and emitting no warning. System events already override getPriority() to return their fixed value, so the unset field is never consulted.
  • EventManager.setEventPriority() now returns after warning a robot that it may not change a system event's priority, so the request is genuinely ignored (previously it fell through and applied/clamped the value).

Security

isCriticalEvent() is package-private to robocode and the robot class loader refuses to define any robocode.* class from robot bytes (delegating to the trusted parent loader regardless of the security flag), so robots cannot override it to abuse this path.

System events (WinEvent, BattleEndedEvent, SkippedTurnEvent, RoundEndedEvent, etc.) have a fixed priority of 100, which is outside the 0-99 range allowed for robot-defined events. When something stamps such an event with its default priority, Event.setPriorityHidden() clamped it to 99 and printed misleading 'SYSTEM: Priority must be between 0 and 99' / 'Priority for robocode.WinEvent will be 99' warnings to the robot console.

Fix setPriorityHidden() to return early for critical (system) events, leaving their priority untouched and emitting no warning. Also make EventManager.setEventPriority() return after warning a robot that it may not change a system event's priority, so the change is genuinely ignored.

isCriticalEvent() is package-private and robocode.* classes cannot be defined by the robot class loader, so robots cannot override it to abuse this path.
@pavelsavara pavelsavara self-assigned this Jun 21, 2026
@pavelsavara pavelsavara merged commit 87af907 into robo-code:main Jun 22, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants